#ifndef __INCLUDED_EVEREST_ODBC_ENVIRONMENT_H
#define __INCLUDED_EVEREST_ODBC_ENVIRONMENT_H

#include <everest/basedef.h>
#include <sql.h>
#include <sqlext.h>

#define EVEREST_ODBC_SUCCESS(ret) (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)


BEGIN_NAMESPACE_EVEREST

namespace odbc
{
	/**
	 * @brief The ODBC DriverInfo struct
	 */
	class DriverInfo
	{
		struct PData;
	public:
		DriverInfo(const SQLCHAR *pszDesc, SQLSMALLINT desclen, const SQLCHAR *pAttribs, SQLSMALLINT attrlen);
		DriverInfo(const DriverInfo& drv);
		virtual ~DriverInfo() ;

		DriverInfo& operator=(const DriverInfo& drv) ;

		const char *getDescription() const;
		int         getAttribCount() const;
		bool        getAttribute(int index, String& key, String& value) const ;

	private:
		PData *m_pData;
	};

	/**
	 * @brief The ODBC Environment class
	 */
	class Environment
	{
		EVEREST_UNCOPIABLE(Environment)
		struct PData;

	public:
		Environment();
		virtual ~Environment();

		SQLHENV     getHandle() const;  ///<  \brief get Environment handle
		DriverInfo *getDriverInfo(/*in*/ SQLUSMALLINT direction);      ///< /// \brief  numerates driver info.

	protected:
		SQLHENV  m_EnvHandle;
		PData   *m_pData;
	};
	typedef CommonPtr<Environment> EnvironmentPtr;

} // end of namespace odbc

END_NAMESPACE_EVEREST


#endif // __INCLUDED_EVEREST_ODBC_ENVIRONMENT_H
